package thread;

import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description: null
 * @Project: testDemo
 * @Author: hjibo
 * @CreateDate: 2019/2/22 09:06
 * @ModificationHistory: （who whatTime doWhat）
 */
public class MainMarch {

public static void main(String[] args) {
    // 创建一个线程池
    ExecutorService executor = Executors.newFixedThreadPool(12);
    // 创建一个10人小分队
    CyclicBarrier barrier = new CyclicBarrier(8);
    try {
        executor.execute(new ThreadMarch("小明",barrier));
        executor.execute(new ThreadMarch("小强",barrier));
        executor.execute(new ThreadMarch("田鸡",barrier));
        executor.execute(new ThreadMarch("浩南",barrier));
        executor.execute(new ThreadMarch("呆鸡哥",barrier));
        executor.execute(new ThreadMarch("路飞",barrier));
        executor.execute(new ThreadMarch("李白",barrier));
        executor.execute(new ThreadMarch("一页书",barrier));
        executor.execute(new ThreadMarch("袁天罡",barrier));
        executor.execute(new ThreadMarch("大乔",barrier));

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        executor.shutdown();
    }
}
}
